﻿using System;
using System.Windows.Forms;

namespace DragRaceTimer
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {

        }

        private void calculateButton_Click(object sender, EventArgs e)
        {
            // Declare Varables
            // d = distance in feet
            // s = time in seconds
            // f = feet in a mile
            // shr = seconds in an hour
            // r = unrounded results.
            // rr = results rounded
            // results = results of the math after rounding
            Decimal r;
            Decimal rr;
            Decimal f = 5280;   // 5280 feet in mile
            Decimal shr = 3600; // 3600 seconds in hour

            //Grabs numbers from text boxes, converts them to Decimal's for calcs
            Decimal d = Decimal.Parse(feetTextBox.Text);
            Decimal s = Decimal.Parse(secondsTextBox.Text);

            //Performs math.  ((distance traveled in feet / total seconds)* seconds in hour) / feet in mile
            r = (((d / s)*shr)/f);

            //Dump results to label and round it to the nearest xx.xx
            rr =  Math.Round(r, 2);
            string results = Convert.ToString(rr);
            resultsLabel.Text = results;
        }
    }
}
